home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_11 / 9n11086a < prev    next >
Text File  |  1991-04-04  |  3KB  |  110 lines

  1.  
  2.  
  3.  
  4.        /***********************************************
  5.        *
  6.        *       file d:\cips\roundoff.c
  7.        *
  8.        *       Functions: This file contains
  9.        *          main
  10.        *
  11.        *       Purpose:
  12.        *          This program takes an image file and
  13.        *          rounds if off by writing it to an new
  14.        *          file that has an even multiple of
  15.        *          rows and cols.
  16.        *
  17.        *       External Calls:
  18.        *          tiff.c - read_tiff_header
  19.        *          rtiff.c - read_tiff_image
  20.        *          gin.c - get_image_name
  21.        *          gpcips - get_parameters
  22.        *          numcvrt.c - get_integer
  23.        *          wtiff.c - create_allocate_tiff_file
  24.        *                    write_array_into_tiff_image
  25.        *
  26.        *       Modifications:
  27.        *          31 March 1991 - created
  28.        *
  29.        *************************************************/
  30.  
  31. #include "d:\cips\cips.h"
  32.  
  33.  
  34.  
  35. short the_image[ROWS][COLS];
  36. short out_image[ROWS][COLS];
  37.  
  38. main()
  39. {
  40.    char     caption[80], name[80], name2[80], rep[80];
  41.    int      count, i, ie, il, j, le, length, ll, 
  42.             new_ie, new_il, vertical, width;
  43.    struct   tiff_header_struct image_header;
  44.  
  45.  
  46.    _setvideomode(_TEXTC80);      /* MSC 6.0 statements */
  47.    _setbkcolor(1);
  48.    _settextcolor(7);
  49.    _clearscreen(_GCLEARSCREEN);
  50.  
  51.  
  52.    new_ie = 1;
  53.    new_il = 1;
  54.    il     = 1;
  55.    ie     = 1;
  56.    ll     = ROWS+1;
  57.    le     = COLS+1;
  58.  
  59.    strcpy(name,  "d:/pix/adam256.tif");
  60.    strcpy(name2, "d:/pix/output.tif");
  61.  
  62.    printf("\n\nThis is the ROUNDOFF program");
  63.    printf("\nIt copies a portion of one image file");
  64.    printf("\nto another image file.  The output image");
  65.    printf("\nfile will be a multiple of ROWS and COLS.\n");
  66.  
  67.  
  68.    printf("\nCIPS> Enter input image name\n");
  69.    get_image_name(name);
  70.    printf("\nCIPS> Enter output image name\n");
  71.    get_image_name(name2);
  72.    printf("\nEnter the il and ie where you want to");
  73.    printf("\nstart copying from input image");
  74.    get_parameters(&il, &ie, &ll, &le);
  75.  
  76.    printf("\nEnter number of vertical blocks (100 rows)");
  77.    printf(" __\b\b");
  78.    get_integer(&length);
  79.  
  80.    printf("\nEnter number of horizontal blocks (100 cols)");
  81.    printf(" __\b\b");
  82.    get_integer(&width);
  83.  
  84.    printf("\nCreating the output image file %s", name2);
  85.    read_tiff_header(name, &image_header);
  86.    image_header.image_length = length*ROWS;
  87.    image_header.image_width  = width*COLS;
  88.    create_allocate_tiff_file(name2, &image_header,
  89.                              out_image);
  90.  
  91.    count = 1;
  92.  
  93.    for(i=0; i<length; i++){
  94.       for(j=0; j<width; j++){
  95.          printf("\nRunning %d of %d", count, length*width);
  96.          count++;
  97.          read_tiff_image(name, the_image,
  98.                          il + i*ROWS,
  99.                          ie + j*COLS,
  100.                          il + i*ROWS + ROWS,
  101.                          ie + j*COLS + COLS);
  102.          write_array_into_tiff_image(name2, the_image,
  103.                          new_il + i*ROWS,
  104.                          new_ie + j*COLS,
  105.                          new_il + i*ROWS + ROWS,
  106.                          new_ie + j*COLS + COLS);
  107.       }
  108.    }
  109.  
  110. }  /* ends main */